Problem Challenge 1

K Pairs with Largest Sums (Hard) #

Given two sorted arrays in descending order, find ‘K’ pairs with the largest sum where each pair consists of numbers from both the arrays.

Example 1:

Input: L1=[9, 8, 2], L2=[6, 3, 1], K=3
Output: [9, 3], [9, 6], [8, 6] 
Explanation: These 3 pairs have the largest sum. No other pair has a sum larger than any of these.

Example 2:

Input: L1=[5, 2, 1], L2=[2, -1], K=3
Output: [5, 2], [5, -1], [2, 2] 

Try it yourself #

Try solving this question here:

Output

0.473s

Pairs with largest sum are: []

Mark as Completed
←    Back
Smallest Number Range (Hard)
Next    →
Solution Review: Problem Challenge 1